<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>Banner管理--${fns:getConfig('productName')}</title>
<link href="${ctx}/static/bootstrap/2.3.1/css/docs.css" type="text/css" rel="stylesheet" />
<script src="${ctx}/scripts/img/placeImage.js"  type="text/javascript"></script>
 <script type="text/javascript" src="${ctxStatic}/wangEditor/wangEditor.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// 	wordCount();
	$("#name").focus();
    var E = window.wangEditor
    var editor = new E('#editor')
    editor.customConfig.uploadImgShowBase64 = true
    // 隐藏“网络图片”tab
	editor.customConfig.showLinkImg = false
//  var editor = new E( document.getElementById('#editor') )
    editor.create();
	$("#inputForm").validate({
		rules: {
			sort:{
				number:true,
				min:0
			},
			name:{
				"required":true
			}
		},
		messages: {
			
		},
		submitHandler:function(form){
			if(checkFileName('file') || $('#id').val() != ''){
				if($('#id').val() != '' || isPicture($('#file').val())){
		 			loading("保存中...");
		 			$('#bannerContent').text(editor.txt.html());
		 			form.submit();
				} else{
					$.jBox.tip('图片格式不正确，请重新选择banner图片 ', 'error');
		        	setTimeout("$.jBox.closeTip()", 2000);
				}
			} else{
				$.jBox.tip('请选择banner图片 ', 'info');
	        	setTimeout("$.jBox.closeTip()", 2000);
			}

		},
		errorContainer: "#messageBox",
		errorPlacement: function(error, element) {
			$("#messageBox").text("输入有误，请先更正。");
			if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
				error.appendTo(element.parent().parent());
			} else {
				error.insertAfter(element);
			}
		}
	});
});

</script>
<style>
	.w-e-text-container,.w-e-toolbar{
	 width:70%;
	 margin:auto;
	}
</style>
</head>
<body>
<ul class="nav nav-tabs" style="margin:0 4px;">
		<li>
			<a href="${ctx}/banner/show.do?top=${fns:encodeParam(top)}&left=${fns:encodeParam(left)}">
				<i class="icon icon-edit"></i>&nbsp;Banner列表
			</a>
		</li>
		<li class="active">
			<a href="${ctx}/banner/input.do?top=${fns:encodeParam(top)}&left=${fns:encodeParam(left)}"> 
				<i class="icon icon-list"></i>&nbsp;${not empty
				entity.id?'修改':'新增'}
			</a>
		</li>
	</ul>
	<form id="inputForm" action="${ctx}/banner/save.do?top=${fns:encodeParam(top)}&left=${fns:encodeParam(left)}"
		method="post"  class="form-horizontal m"  enctype="multipart/form-data">
		<input type="hidden" name="id" id="id" value="${entity.id}" /> 
		<input type="hidden" name="token" value="${token}">
		<tags:message content="${msg}" />
		<fieldset>
    			<legend>banner信息</legend>
				<div class="control-group">
					<label class=" control-label">名称<font style="color:red;">*</font>:</label>
					<div class="controls">
					  <input class=" required" id="name" name="name"
							type="text" value="${entity.name}">
					</div>
				</div>
				<div class="control-group">
					<label class=" control-label">排序<font style="color:red;">*</font>:</label>
					<div class="controls">
					  <input class=" required" id="sort" name="sort"
							type="text" value="${entity.sort}">
					</div>
				</div>
				<div class="control-group">
					<label class=" control-label">显示:</label>
					<div class="controls">
					 <pt:code name="isShow" category="1000" hasEmpty="false" default="${entity.isShow}"></pt:code>
					</div>
				</div>
				<div class="control-group">
					<label class=" control-label">上传图片:</label>
					<div class="controls">
					 <input id="file" type="file" name="file" class="file" value="${file}"/>
					</div>
				</div>
				<label style="width:160px;text-align:right;">banner详情:</label>
					<div id="editor" >
						${entity.bannerContent}
					</div>
					<textarea name="bannerContent" id="bannerContent" style="display:none">${entity.bannerContent}</textarea>
		<fieldset>
      <div class="form-actions" style="text-align:center;padding-left:0px;">
				<input id="btnSubmit" class="btn btn-primary" type="submit"
					value="保 存" />
					&nbsp; 
<input id="btnCancel" class="btn" type="button" value="返 回" onclick="JavaScript:history.go(-1);" />
	 </div>
	</form>
	
<span id="clock"></span>
</body>
</html>